#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int n,l,r;
	scanf("%d%d%d",&n,&l,&r);
	int x=l%n;
	if(l+(n-1-x)<=r) printf("%d\n",n-1);
	else printf("%d\n",r-l+x);
	return 0;
}
